package com.xgp.company.结构性模式.代理模式.静态代理.Demo2;

/**
 * 代理角色，增加日志的功能
 */
public class UserServiceProxy implements UserService {

    private UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @Override
    public void add() {
        userService.add();
        log("add");
    }

    @Override
    public void del() {
        userService.del();
        log("del");
    }

    @Override
    public void update() {
        userService.update();
        log("update");
    }

    @Override
    public void query() {
        userService.query();
        log("query");
    }

    public void log(String msg) {
        System.out.println("使用了" + msg + "方法！");
    }
}
